#!/usr/bin/env bash
#yum -y -d 1 install mysql mysql-server mysql-devel
#service mysqld start
#chkconfig mysqld on
cd /Workspace

if [ ! -d /var/data ]
then
    mkdir /var/data
fi

tar -zxvf mysql-5.1.56.tar.gz
cd mysql-5.1.56

groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql

./configure --prefix=/tools/mysql --enable-assembler --with-mysqld-user=mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-charset=gbk --enable-thread-safe-client --with-big-tables --with-plugins=innobase --without-debug  --localstatedir=/var/data
make && make install
cp -f support-files/my-large.cnf   /etc/my.cnf
chown -R mysql.mysql /tools/mysql
/tools/mysql/bin/mysql_install_db --user=mysql
chown -R mysql.mysql /var/data
/tools/mysql/bin/mysqld_safe --user=mysql &
cp   support-files/mysql.server   /etc/rc.d/init.d/mysqld
chmod   755   /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
echo "/tools/mysql">>/etc/ld.so.conf
ldconfig
ldconfig -v
echo "export PATH=$PATH:/tools/mysql/bin">>/etc/profile
source /etc/profile
